﻿$(document).ready(function () {
    $("#btn_login").bind("click", function () {
        var mail = $("#form_email").val();
        var pass = $("#form_password").val();
        var issave = "0";
        if ($("#form_remember").attr("checked") == true) {
            issave = "1";
        }

        var sendstring = "{name:'" + mail + "',pass:'" + pass + "',issave:'" + issave + "'}";
        //alert(sendstring);

        if (!$("#form_email").val()) {

            loadalert(" 请输入Email ");
            $("#form_email").focus();
        }
        else if (!$("#form_password").val()) {
            loadalert(" 请输入密码 ");
            $("#form_password").focus();

        }
        else {
            showloading("正在登录..");
            $.ajax({
                type: "POST",
                contentType: "application/json",
                url: "/webservices/login.asmx/userlogin",
                data: sendstring,
                dataType: "json",
                error: function (x, e) {
                    alert(e);
                },
                success: function (msg) {
                    //判断登录情况
                    if (msg.d == "1") {

                        //登录成功
                        window.location.href = "/u/default.aspx";
                    }
                    else {
                        loadalert(" 登录失败 用户名或密码错误 ")
                    }
                }
            });
        }
    });

});

$(document).ready(function () {
    $('#aspnetForm').submit(function () { $("#btn_login").click(); return false });
});
